home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Libraries / SAT 2.3.8 / Libraries & Documentation / Add-ons / Sprite behavior / SATGridStubs.p next >
Text File  |  1995-09-15  |  2KB  |  92 lines

  1. {*** This copy of SATGridStubs modified for <your project here>! ***}
  2.  
  3. {=====================================================}
  4. {============= Grid display grid-bound animation ==============}
  5. {=====================================================}
  6.  
  7. {SATGridStubs is the non-reusable part of the SATGridToolbox and SATStrictGridToolbox units in the SAT Add-ons.}
  8. {You should make a copy for your project and modify it to suit your needs.}
  9. {Here you define the shape and size of your grid, and define how to draw it.}
  10. {You need a separate version of this file for every game.}
  11.  
  12. unit SATGridStubs;
  13.  
  14. interface
  15.  
  16.     uses
  17.         SAT;
  18.  
  19.     type
  20.         GridSpaceType = Char;
  21.  
  22.     const
  23.         kFreeSpace = ' ';
  24.         kArraySizeH = 15;
  25.         kArraySizeV = 12;
  26.  
  27. (*Size of the tiles*)
  28.         kTileSizeH = 24;
  29.         kTileSizeV = 24;
  30.  
  31.     var
  32.         tileArray: packed array[0..kArraySizeH, 0..kArraySizeV] of Char;
  33.  
  34.     procedure InitTiles;
  35.     procedure DrawTile (h: Integer; v: Integer);
  36.  
  37. implementation
  38.  
  39. (* Pictures used for drawing the grid, in DrawTile. *)
  40. (* Feel free to replace them with, for example, FacePtrs as needed. *)
  41. (* (Using Faces instead of Pictures would be a lot faster!) *)
  42.  
  43.     var
  44.         wallTile, floorTile: PicHandle;
  45.  
  46. (* Preload graphics used by DrawTile! *)
  47.  
  48.     procedure InitTiles;
  49.         var
  50.             h, v: Integer;
  51.     begin
  52.         wallTile := GetPicture(128);
  53.         floorTile := GetPicture(129);
  54.  
  55.         for h := 0 to kArraySizeH do
  56.             for v := 0 to kArraySizeV do
  57.                 begin
  58.                     tileArray[h, v] := kFreeSpace;
  59.                 end;
  60.         tileArray[5, 5] := 'x';
  61.         tileArray[6, 5] := 'x';
  62.         tileArray[7, 5] := 'x';
  63.  
  64.         tileArray[7, 8] := 'x';
  65.         tileArray[8, 8] := 'x';
  66.         tileArray[9, 8] := 'x';
  67.  
  68.         tileArray[7, 3] := 'x';
  69.         tileArray[8, 3] := 'x';
  70.         tileArray[9, 3] := 'x';
  71.         tileArray[10, 3] := 'x';
  72.         tileArray[11, 3] := 'x';
  73.  
  74.         tileArray[5, 6] := 'x';
  75.         tileArray[5, 7] := 'x';
  76.         tileArray[5, 8] := 'x';
  77.     end;
  78.  
  79. (* Draw a tile *)
  80.  
  81.     procedure DrawTile (h: Integer; v: Integer);
  82.         var
  83.             tileRectangle: Rect;
  84.     begin
  85.         SetRect(tileRectangle, h * kTileSizeH, v * kTileSizeV, (h + 1) * kTileSizeH, (v + 1) * kTileSizeV);
  86.         if (tileArray[h][v] = kFreeSpace) then
  87.             DrawPicture(floorTile, tileRectangle)
  88.         else
  89.             DrawPicture(wallTile, tileRectangle);
  90.     end; (*DrawTile*)
  91.  
  92. end.